package com.unionpay.db;

import java.util.Date;
import java.util.List;

import com.unionpay.async.AsyncTask;
import com.unionpay.async.AsyncTaskPool;
import com.unionpay.entity.AnchorcofigEntity;
import com.unionpay.mapper.AnchorcofigEntityMapper;
import com.unionpay.util.StrUtil;

/**
 * anchorcofig表操作
 * 
 * @author 瞿峰
 * @since 2016年5月5日
 */
public class TblAnchorcofig {
	static AnchorcofigEntityMapper mapper = Mybaties.getMapper(AnchorcofigEntityMapper.class);

	public static int save(String anchortype, String bizid, String anchorinterval, String anchorrecords, Date startdate) {
		AnchorcofigEntity entity = new AnchorcofigEntity();
		entity.setAnchortype(anchortype);
		entity.setBizid(bizid);
		if (!StrUtil.hasEmpty(anchorinterval)) {
			entity.setAnchorinterval(anchorinterval);
		}
		if (!StrUtil.hasEmpty(anchorrecords) && Integer.valueOf(anchorrecords) > 0) {
			entity.setAnchorrecords(anchorrecords);
		}
		entity.setAnchorstartdate(startdate);
		entity.setReccrtts(new Date());
		mapper.insert(entity);
		return entity.getAnchorcofigid();
	}

	public static AnchorcofigEntity selectById(String anchorconfigid) {
		return mapper.selectByid(anchorconfigid);
	}

	public static AnchorcofigEntity selectByBizId(String bizId) {
		return mapper.selectBybizid(bizId);
	}

	public static List<AnchorcofigEntity> selectAll() {
		return mapper.selectAll();
	}

	public static void deleteBybizid(String bizid) {
		mapper.deleteBybizid(bizid);
	}
	public static AnchorcofigEntity selectAllBybizid(String bizId) {
		return mapper.selectAllBybizid(bizId);
	}
	public static void update(Integer anchorconfigid,String anchortype, String bizid, String anchorinterval, String anchorrecords, Date startdate) {
		AnchorcofigEntity entity=new AnchorcofigEntity();
		entity.setAnchorcofigid(anchorconfigid);
		entity.setBizid(bizid);
		entity.setAnchorinterval(anchorinterval);
		entity.setAnchorrecords(anchorrecords);
		entity.setAnchorstartdate(startdate);
		entity.setAnchortype(anchortype);
		entity.setReccrtts(new Date());
		mapper.updateByid(entity);
	}
	
}
